package com.atguigu.srb.rabbitutil.service.impl;

import com.atguigu.srb.rabbitutil.service.MQService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: srb
 * @author: 龙龙
 * @create: 2022-02-26 16:27
 * @description:
 **/
@Service
@Slf4j
public class MQServiceImpl implements MQService {

    @Autowired
    RabbitTemplate rabbitTemplate;

    /**
     *  发送消息
     * @param exchange 交换机
     * @param routingKey 路由
     * @param message 消息
     */
    public boolean sendMessage(String exchange, String routingKey, Object message) {
        log.info("发送消息...........");
        rabbitTemplate.convertAndSend(exchange, routingKey, message);
        return true;
    }
}
